import { GTextFormat } from "../../../common/GTextFormat";
import { Language } from "../../../../extend/language/Language";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { EToplistType } from "../../../../Message/Public/EToplistType";
import { PetRankItem } from "./PetRankItem";
type int = number;
//class PetRankSprite
    
    export  class PetRankSprite /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._itemArr = [];
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this._headTf = new GTextFormat("", 12, 16777113);
            this._rankTxt = this.createTxt(0, 0, 100, 30, Language.getString(32063));
            this._nameTxt = this.createTxt(62, 0, 100, 30, Language.getString(32093));
            this._levelTxt = this.createTxt(138, 0, 100, 30, Language.getString(32069));
            this._ownerTxt = this.createTxt(210, 0, 100, 30, Language.getString(32094));
            this._campTxt = this.createTxt(288, 0, 100, 30, Language.getString(32068));
            this._attributeTxt = this.createTxt(355, 0, 100, 40, Language.getString(32095));
            this._rangeTxt = this.createTxt(405, 0, 100, 60, Language.getString(32070));
            var loc1=ObjCreate.createBg(0, 23, 460, 2, this, ImagesConst.SplitLine);
            this.createItem();
            return;
        }

        /* internal  */createTxt(arg1: int, arg2: int, arg3: int, arg4: int, arg5: string): Object /* flash.text.TextField */
        {
            var loc1=null;
            (loc1 = new Object /* flash.text.TextField */()).x = arg1;
            loc1.y = arg2;
            loc1.width = arg3;
            loc1.height = arg4;
            loc1.text = arg5;
            loc1.selectable = false;
            loc1.setTextFormat(this._headTf);
            addChild(loc1);
            return loc1;
        }

        public resetTextPos(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case EToplistType._EToplistTypePetTalent:
                {
                    this._attributeTxt.text = Language.getString(32095);
                    break;
                }
                case EToplistType._EToplistTypePetGrowth:
                {
                    this._attributeTxt.text = Language.getString(32096);
                    break;
                }
                case EToplistType._EToplistTypePetSpirit:
                {
                    this._attributeTxt.text = Language.getString(32097);
                    break;
                }
            }
            this._attributeTxt.setTextFormat(this._headTf);
            return;
        }

        /* internal  */createItem(): void
        {
            var loc3=null;
            var loc1=0;
            var loc2=30;
            var loc4=0;
            while (loc4 < 10) 
            {
                loc3 = new PetRankItem();
                loc3.x = loc1;
                loc3.y = loc2;
                loc2 = loc2 + loc3.height;
                loc3.doubleClickEnabled = true;
                this._itemArr.push(loc3);
                loc3.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickItemHandler);
                addChild(loc3);
                ++loc4;
            }
            return;
        }

        /* internal  */onMouseClickItemHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                loc1 = this._itemArr[loc2] as PetRankItem;
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            if (typeof arg1.target === "petrankitem") 
            {
                loc1 = arg1.target as PetRankItem;
                loc1.onPetItemClick(arg1);
            }
            else if (typeof arg1.currentTarget === "petrankitem") 
            {
                loc1 = arg1.currentTarget as PetRankItem;
                loc1.onPetItemClick(arg1);
            }
            return;
        }

        public setData(arg1: Array<any>, arg2: Boolean, arg3: int): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < 10) 
            {
                (loc1 = this._itemArr[loc2] as PetRankItem).updateItem(arg1[loc2], arg3);
                if (loc1.isDraw) 
                {
                    loc1.clearBgColor();
                }
                ++loc2;
            }
            if (this._itemArr && this._itemArr.length > 0) 
            {
                if ((loc1 = this._itemArr[0] as PetRankItem).data != null) 
                {
                    loc1.drawGrayColor();
                }
            }
            return;
        }

        /* internal */ /* var */_headTf: Object /* flash.text.TextFormat */;

        /* internal */ /* var */_rankTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_levelTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_ownerTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_campTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_attributeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_rangeTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_itemArr: Array<any>;
    }
